<template>
  <div class="search">
    <div class="title">用户反馈</div>
    <div class="searchBox">
      <label>
        <span>意见类型</span>
        <el-select
          clearable
          placeholder="请选择"
          v-model="commentType"
          @change="commitType"
        >
          <el-option
            v-for="(item, index) in typeList"
            :label="item.commentTypeName + ` (${item.count})`"
            :key="index"
            :value="index !== 0 ? item.commentTypeName : ''"
          ></el-option>
        </el-select>
      </label>

      <label>
        <span>上传时间</span>
        <el-date-picker
          v-model="$store.state.feedback.date"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
        ></el-date-picker>
      </label>

      <div class="btns">
        <span class="search" @click="search">查询</span>
        <span class="reset" @click="reset">重置</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      commentType: ''
    }
  },
  computed: {
    typeList () {
      return this.$store.state.feedback.typeList
    }
  },
  methods: {
    commitType () {
      this.$store.commit('feedback/set_commentType', this.commentType)
    },
    search () {
      this.$store.commit('feedback/set_commentDTO_index', 1)
      this.$store.dispatch('feedback/getList')
    },
    async reset () {
      await this.$store.dispatch('feedback/reset')
      await this.search()
    }
  },
  async created () {
    await this.$store.dispatch('feedback/reset')
    await this.$store.dispatch('feedback/getTypeList')
    await this.$store.dispatch('feedback/getList')
  }
}
</script>

<style scoped lang="scss">
::v-deep .el-input__inner {
  height: 36px !important;
}
::v-deep .el-range-separator {
  width: 10%;
}
::v-deep .el-date-editor--daterange.el-input__inner {
  width: 320px;
}

.search {
  .title {
    height: 90px;
    line-height: 90px;
    color: #333;
    font-size: 24px;
    font-weight: bold;
  }

  .searchBox {
    padding: 24px 30px;
    background-color: #fff;
    border-radius: 5px;
    label {
      margin-right: 60px;
      span {
        color: #666;
        font-size: 14px;
        margin-right: 12px;
      }

      .el-select {
        width: 240px;
      }
    }

    .btns {
      position: relative;
      width: 184px;
      display: inline-block;
      vertical-align: top;
      height: 36px;
      span {
        position: absolute;
        width: 84px;
        height: 36px;
        border-radius: 18px;
        line-height: 36px;
        font-size: 14px;
        cursor: pointer;
        text-align: center;
      }
      .search {
        background-color: #4868FF;
        color: #fff;
      }
      .reset {
        right: 0;
        border: 1px solid #4868FF;
        color: #4868FF;
        background-color: #fff;
      }
    }
  }
}
</style>
